from okx import Grid
import json

# OKX API配置
API_KEY = '6860449c-c557-434b-9eff-2c2546959cc7'
API_SECRET = '4F532857977CA2410D335AB85ED846A5'
PASSPHRASE = 'Pfy@132465'

client = Grid.GridAPI(api_key=API_KEY, api_secret_key=API_SECRET, passphrase=PASSPHRASE, flag='0')
    
# 请求体
body = {
    "instId": "SOL-USDT",
    "algoOrdType": "grid",
    "maxPx": "150",
    "minPx": "140",
    "gridNum": "10",
    "runType": "1",
    "baseSz": "1",
    "triggerParams": [
        {
            "triggerAction": "stop",
            "triggerStrategy": "price",
            "triggerPx": "1000"
        }
    ]
}

# 发送请求
response = client.grid_order_algo(instId='SOL-USDT', algoOrdType='grid', maxPx='142', minPx='138', gridNum='20', runType='1', tpTriggerPx='153', quoteSz='300', sz='高频做市')

# 打印响应
print(json.dumps(response, indent=4))